package com.oracle2mysql.migration;

import java.util.Properties;

/**
 * 用于调试DECODE函数转换的简单类
 */
public class DecodeFunctionDebug {
    
    public static void main(String[] args) {
        try {
            System.out.println("\n===== DecodeFunctionDebug 开始 =====");
            
            // 初始化SQL转换器
            Properties config = new Properties();
            String functionMappingPath = "src/main/resources/function-mapping.json";
            FunctionMapper functionMapper = new FunctionMapper(config, functionMappingPath);
            SqlConverter sqlConverter = new SqlConverter(functionMapper, config);
            
            // 测试基本的DECODE函数 - 使用我们新添加的public测试方法
            String oracleSql = "SELECT DECODE(status, 'A', 'Active', 'I', 'Inactive', 'Unknown') FROM users";
            System.out.println("\n1. 测试基本DECODE函数");
            String result1 = sqlConverter.testDecodeToCaseDirect(oracleSql);
            
            // 测试数值参数的DECODE函数
            String numericSql = "SELECT DECODE(score, 100, 'perfect', 90, 'excellent', 'good') FROM exams";
            System.out.println("\n2. 测试数值参数的DECODE函数");
            String result2 = sqlConverter.testDecodeToCaseDirect(numericSql);
            
            // 测试简单的DECODE函数调用（不包含SELECT语句）
            String simpleSql = "DECODE(status, 'A', 'Active', 'Inactive')";
            System.out.println("\n3. 测试简单DECODE函数调用");
            String result3 = sqlConverter.testDecodeToCaseDirect(simpleSql);
            
            System.out.println("\n===== DecodeFunctionDebug 结束 =====");
            
        } catch (Exception e) {
            System.err.println("调试过程中发生错误:");
            e.printStackTrace();
        }
    }
}